//
//  YunkuPlatformHomeViewController.m
//  reSearchDemo
//
//  Created by badboy on 15/10/26.
//  Copyright © 2015年 Kiwaro. All rights reserved.
//

#import "YunkuPlatformHome.h"
#import "PlatformFunction.h"
#import "PlatformMerchantsVC.h"
#import "PlatformManagement.h"
#import "PlatformMy.h"
#import "KAlertView.h"

@interface YunkuPlatformHome () <UITabBarControllerDelegate>

@property (nonatomic, retain) OnePlatformModel *model;

@property (nonatomic, retain) PlatformFunction *platformFunctionVC;
@property (nonatomic, retain) PlatformManagement *platformManagementVC;
@property (nonatomic, retain) PlatformMerchantsVC *platformMerchantsVC;
@property (nonatomic, retain) PlatformMy *myVC;

@end

@implementation YunkuPlatformHome

- (id)initWithPlatformModel:(OnePlatformModel *)model {
    self = [super init];
    if (self) {
        self.model = model;
        
        
        self.platformFunctionVC = [[PlatformFunction alloc] initWithPlatformModel:self.model];
        self.platformFunctionVC.tabBarItem.image = [UIImage imageNamed:@"功能-平台"];
        self.platformFunctionVC.tabBarItem.title = @"功能";
        
        self.platformManagementVC = [[PlatformManagement alloc] initWithPlatformModel:self.model];
        self.platformManagementVC.tabBarItem.image = [UIImage imageNamed:@"管理-平台"];
        self.platformManagementVC.tabBarItem.title = @"管理";
        
        self.platformMerchantsVC = [[PlatformMerchantsVC alloc] initWithPlatformModel:self.model];
        self.platformMerchantsVC.tabBarItem.image = [UIImage imageNamed:@"商家-平台"];
        self.platformMerchantsVC.tabBarItem.title = @"商家";
        
        self.myVC = [[PlatformMy alloc] initWithPlatformModel:self.model];
        self.myVC.tabBarItem.image = [UIImage imageNamed:@"我的-平台"];
        self.myVC.tabBarItem.title = @"我的";
        
//        self.delegate = self;
        self.viewControllers = @[self.platformFunctionVC,self.platformManagementVC,self.platformMerchantsVC,self.myVC];
        self.selectedIndex = 0;
        self.title = self.model.name;
        
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.delegate = self;
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"用户" style:UIBarButtonItemStylePlain target:self action:@selector(userAction:)];
    self.navigationController.navigationBar.hidden = YES;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

#pragma mark -- 关注用户列表 --
- (void)userAction:(id)sender {
    
}

- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController NS_AVAILABLE_IOS(3_0) {
    if (viewController == self.platformMerchantsVC && self.model.rzstatus != 1) {
        [KAlertView showType:KAlertTypeNone text:@"平台还没认证" for:1.45 animated:YES];
        return NO;
    }
    return YES;
}

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
    
}

@end
